package com.rede.didiok.rank.controller;

import java.util.Arrays;
import java.util.Map;

// import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.rede.didiok.rank.entity.VoteRecordEntity;
import com.rede.didiok.rank.service.VoteRecordService;
import com.rede.didiok.common.utils.PageUtils;
import com.rede.didiok.common.utils.R;



/**
 * 投票记录表
 *
 * @author Rede
 * @email didiok@foxmail.com
 * @date 2023-07-20 22:09:24
 */
@RestController
@RequestMapping("rank/voterecord")
public class VoteRecordController {
    @Autowired
    private VoteRecordService voteRecordService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    // @RequiresPermissions("rank:voterecord:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = voteRecordService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{recordId}")
    // @RequiresPermissions("rank:voterecord:info")
    public R info(@PathVariable("recordId") Long recordId){
		VoteRecordEntity voteRecord = voteRecordService.getById(recordId);

        return R.ok().put("voteRecord", voteRecord);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    // @RequiresPermissions("rank:voterecord:save")
    public R save(@RequestBody VoteRecordEntity voteRecord){
		voteRecordService.save(voteRecord);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    // @RequiresPermissions("rank:voterecord:update")
    public R update(@RequestBody VoteRecordEntity voteRecord){
		voteRecordService.updateById(voteRecord);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    // @RequiresPermissions("rank:voterecord:delete")
    public R delete(@RequestBody Long[] recordIds){
		voteRecordService.removeByIds(Arrays.asList(recordIds));

        return R.ok();
    }

}
